package com.design.FactoryMode.mode2;

import com.design.FactoryMode.demo.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 定义工厂类
 */
public class SmsCheckFactory {

    private static  final Map<Integer,SmsService> smsInstance = new HashMap<Integer, SmsService>();

    static {
        smsInstance.put(1,new RegisterServiceImpl());
        smsInstance.put(2,new ForgetPwdServiceImpl());
        smsInstance.put(3,new PayPwdServiceImpl());
        smsInstance.put(4,new WithdrawServiceImpl());
    }

    /**
     * 创建实例
     * @param type 类型 1：用户注册  2：找回密码  3：修改支付密码   4：提现
     */
    public static SmsService createSmsInstance(Integer type){
        return null == type ? null : smsInstance.get(type);
    }

}
